package com.wasion.pwportable.protocol.analyzer.indicator;

import com.wasion.core.util.ConverterXBaseUtil;
import com.wasion.pwportable.protocol.analyzer.AbstractAnalyzer;

/**
 * 
 * @ClassName: IndicatorInfo_Analyzer
 * @Description: 1F. 设备本身相关信息（本组信息仅支持点对点方式读取）
 * @author 高意
 * @date 2014-9-10 下午5:28:43
 * 
 */
public class IndicatorInfo_Analyzer extends AbstractAnalyzer {

	@Override
	public void dataAnalysis(String ackBS) {

		// 硬件版本号
		String data = ackBS.substring(DATABITSTART, DATABITSTART + 16);
		String hwVerD = data.substring(14, 16) + data.substring(12, 14)
				+ data.substring(10, 12) + data.substring(8, 10)
				+ data.substring(6, 8) + data.substring(4, 6)
				+ data.substring(2, 4) + data.substring(0, 2);

		String verH = ConverterXBaseUtil.decode(hwVerD);
		StringBuffer sb = new StringBuffer();
		sb.append(verH);
		result.setHwVersion(sb.reverse().toString());

		// 软件版本号
		data = ackBS.substring(DATABITSTART + 16, DATABITSTART + 32);
		String swVerD = data.substring(14, 16) + data.substring(12, 14)
				+ data.substring(10, 12) + data.substring(8, 10)
				+ data.substring(6, 8) + data.substring(4, 6)
				+ data.substring(2, 4) + data.substring(0, 2);

		String verS = ConverterXBaseUtil.decode(swVerD);
		StringBuffer sb2 = new StringBuffer();
		sb2.append(verS);
		result.setSwVersion(sb2.reverse().toString());

		// 通信短码
		data = ackBS.substring(DATABITSTART + 32, DATABITSTART + 38);
		String devIdD = data.substring(4, 6) + data.substring(2, 4)
				+ data.substring(0, 2);
		result.setiAddress(devIdD);
	}
}
